package com.czg.designmode.prototype;

import java.util.HashMap;
import java.util.Map;

/**
 * 克隆管理类
 *
 * @author chenzhigang
 */
public class CloneManager {

    private Map<String, Shape> shapeMap = new HashMap<>();

    public CloneManager() {
        shapeMap.put("circle", new Circle());
        shapeMap.put("rectangle", new Rectangle());
        shapeMap.put("square", new Square());
    }

    public void addShape(String shapeId, Shape shape) {
        shapeMap.put(shapeId, shape);
    }

    public Shape getShape(String shapeId) {
        Shape shape = shapeMap.get(shapeId);
        return (Shape) shape.clone();
    }

}
